<template>
  <div class="travelOrder">
    <!-- 查询条件 -->
    <el-form :model="results" :inline="true" size="mini" ref="ruleForm" label-width="100px">
      <div style="margin:20px">
        <el-form-item label="团类型">
          <el-select v-model="results.groupType" placeholder="请选择">
            <el-option v-for="item in groupType" :key="item.label" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="支付状态">
          <el-select v-model="results.payStatus" placeholder="请选择">
            <el-option v-for="item in options" :key="item.label" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="团名称">
          <el-input v-model="results.groupName"></el-input>
        </el-form-item>
        <el-form-item label="订单号">
          <el-input v-model="results.orderId"></el-input>
        </el-form-item>
        <el-form-item label="会员手机号">
          <el-input v-model="results.customerPhone"></el-input>
        </el-form-item>
        <!-- <el-form-item label="会员卡号">
          <el-input v-model="results.supplierName"></el-input>
        </el-form-item> -->
        <el-form-item label="团号">
          <el-input v-model="results.groupNumber"></el-input>
        </el-form-item>
      </div>
      <div style="margin-top:20;margin-left: 80%;">
        <el-form-item>
          <!-- <el-button type="primary" @click="addproduct">新增</el-button> -->
          <el-button type="primary" @click="viewproduct">查询</el-button>
          <!-- <el-button @click="application">导出报名表</el-button> -->
          <!-- <el-button @click="orderstatistics">订单统计表</el-button> -->
        </el-form-item>
      </div>
    </el-form>
    <!-- 表格数据 -->
    <el-table :data="tableData"
      :header-cell-style="{ color: '#fff', background: '#6090EC', fontSize: '11px', fontWeight: 'normal' }" size="mini"
      border>
      <el-table-column prop="orderId" label="订单号" width="100">
      </el-table-column>
      <el-table-column prop="groupType" label="团类型" width="150">
        <template slot-scope="scope">
          <template v-if="scope.row.groupType=='domesticGroup'">国内团</template>
          <template v-if="scope.row.groupType=='foreignMissions'">国外团</template>
        </template>
      </el-table-column>
      <el-table-column prop="groupName" label="团名称" width="100">
      </el-table-column>
      <el-table-column prop="groupNumber" label="团号" width="100">
      </el-table-column>
      <el-table-column prop="customerName" label="会员姓名"></el-table-column>
      <el-table-column prop="customerPhone" label="会员手机"></el-table-column>
      <el-table-column prop="personCount" label="出行人数"></el-table-column>
      <el-table-column prop="payAmount" label="支付金额"></el-table-column>
      <el-table-column prop="contractNum" label="支付方式"></el-table-column>
      <el-table-column prop="payStatus" label="支付状态">
        <template slot-scope="scope">
           {{scope.row.payStatus | payStatus}}
        </template>
      </el-table-column>
      <el-table-column prop="statusId" label="订单状态">
        <template slot-scope="scope">
          <template v-if="scope.row.statusId==0">未上架</template>
          <template v-if="scope.row.statusId==1">已上架</template>
        </template>
      </el-table-column>
      <!-- <el-table-column prop="statusId" label="审核状态">
        <template slot-scope="scope">
          <template v-if="scope.row.statusId==0">未上架</template>
          <template v-if="scope.row.statusId==1">已上架</template>
        </template>
      </el-table-column>
      <el-table-column prop="statusId" label="是否退款">
        <template slot-scope="scope">
          <template v-if="scope.row.statusId==0">未上架</template>
          <template v-if="scope.row.statusId==1">已上架</template>
        </template>
      </el-table-column>
      <el-table-column prop="statusId" label="退款类型">
        <template slot-scope="scope">
          <template v-if="scope.row.statusId==0">未上架</template>
          <template v-if="scope.row.statusId==1">已上架</template>
        </template>
      </el-table-column> -->
      <el-table-column label="操作" width="260">
        <template slot-scope="scope">
          <!-- <el-button slot="reference" type="primary" size="mini" @click="Mgroupodify(scope.row)">修改支付方式</el-button>
          <el-button slot="reference" type="primary" size="mini" @click="shelves(scope.row)">取消</el-button>
          <el-button slot="reference" type="primary" size="mini" @click="raincheck(scope.row)">改期</el-button>
          <el-button slot="reference" type="primary" size="mini" @click="twocollection(scope.row)">二次收款</el-button> -->
          <el-button slot="reference" type="primary" size="mini" @click="infoBtn(scope.row)">详情</el-button>
          <el-button slot="reference" type="primary" size="mini" @click="confirmation(scope.row)">生成确认函</el-button>
          <el-button slot="reference" type="primary" v-if="scope.row.status ==0" size="mini"
            @click="viewgroup(scope.row)">退订</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
      :page-sizes="[10, 15, 20]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper"
      :total="pageTotal">
    </el-pagination>
    <!-- 详情页面 -->
    <el-dialog title="详情" :visible.sync="infodialogVisible" width="30%">
      <el-form :inline="true" :model="formInfo" class="demo-form-inline" label-width="150">
        <el-form-item label="订单号：">
          <div>{{formInfo.orderId}}</div>
        </el-form-item>
        <el-form-item label="团类型：">
          <div>{{formInfo.groupType}}</div>
        </el-form-item>
        <el-form-item label="团名称：">
          <div>{{formInfo.groupName}}</div>
        </el-form-item>
        <el-form-item label="团号：">
          <div>{{formInfo.groupNumber}}</div>
        </el-form-item>
        <el-form-item label="会员姓名：">
          <div>{{formInfo.customerName}}</div>
        </el-form-item>
        <el-form-item label="会员手机号：">
          <div>{{formInfo.customerPhone}}</div>
        </el-form-item>
        <el-form-item label="出行人数：">
          <div>{{formInfo.contractNum}}</div>
        </el-form-item>
        <el-form-item label="支付金额：">
          <div>{{formInfo.payAmount}}</div>
        </el-form-item>
        <el-form-item label="订单备注：">
          <div>{{formInfo.orderMemo}}</div>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <!-- <el-button @click="infodialogVisible = false">取 消</el-button> -->
        <el-button type="primary" @click="infodialogVisible = false">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog title="退单" :visible.sync="refunddialogVisible" width="30%">
      <span>确认退单吗？</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="refunddialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="getinfoorderRefund">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
  export default {
    name: "travelOrder",
    data() {
      return {
        // 退单弹窗
        refunddialogVisible: false,
        // 详情弹窗
        infodialogVisible: false,
        // 表格数据
        tableData: [],
        // 表格查询条件
        results: {
          groupType: "",
          payStatus: "",
          groupName: "",
          orderId: "",
          customerPhone: "",
          groupNumber: "",
        },
        // 详情数据
        formInfo: {},
        // 分页
        pageSize: 10,
        currentPage: 1,
        pageTotal: 0,
        // 团类型
        groupType: [{
            value: "",
            label: "全部",
          },
          {
            value: "domesticGroup",
            label: "国内团",
          },
          {
            value: "foreignMissions",
            label: "国外团",
          },
        ],
        // 支付状态
        options: [{
            value: "",
            label: "全部",
          },
          {
            value: "unpaid",
            label: "未支付",
          },
          {
            value: "paid",
            label: "已支付",
          },
        ],
        // 退单主键
        refundorderId: ""
      };
    },
    methods: {
      // // 订单统计表
      // orderstatistics() {},
      // // 导出报名表
      // application() {},
      // // 生成确认函
      // confirmation() {},
      // // 二次收款按钮
      // twocollection() {},
      // // 改期按钮
      // raincheck() {},
      // 退款按钮
      viewgroup(row) {
        console.log(row)
        this.refundorderId = row.orderId
        this.refunddialogVisible = true
      },
      // 退订接口
      getinfoorderRefund() {
        this.$axios.getinfoorderRefund({
          orderId: this.refundorderId
        }).then((res) => {
          if (res.code == "200") {
            this.$message({
              message: '退订成功',
              type: 'success'
            });
            this.refunddialogVisible = false

            this.viewproduct()
          }
        });
      },
      // // 取消
      // shelves() {},
      // // 修改支付方式
      // Mgroupodify() {},
      // 详情按钮方式
      infoBtn(row) {
        console.log(row)
        this.formInfo = row
        if (this.formInfo.groupType == 'domesticGroup') {
          this.formInfo.groupType = "国内团"
        } else {
          this.formInfo.groupType = "国外团"
        }
        this.infodialogVisible = true
      },
      // 查询按钮
      viewproduct() {
        localStorage.setItem("pageNum", 1);
        localStorage.setItem("pageSize", 10);
        this.gettravelList()
      },
      // 新增按钮
      addproduct() {},

      // 列表接口
      gettravelList() {
        this.$axios.gettravelList({
          groupType: this.results.groupType,
          payStatus: this.results.payStatus,
          groupName: this.results.groupName,
          orderId: this.results.orderId,
          customerPhone: this.results.customerPhone,
          groupNumber: this.results.groupNumber,
        }).then((res) => {
          if (res.code == "200") {
            this.tableData = res.data
            this.pageTotal = res.total
          }
        });
      },
      //分页
      handleSizeChange(value) {
        localStorage.setItem("pageSize", value);
        localStorage.setItem("pageNum", 1);
        this.gettravelList();
        this.pageSize = value;
      },
      handleCurrentChange(value) {
        localStorage.setItem("pageNum", value);
        localStorage.setItem("pageSize", this.pageSize);
        this.gettravelList();
      },
      search() {
        localStorage.setItem("pageNum", this.currentPage);
        localStorage.setItem("pageSize", 10);
        this.gettravelList();
      },
    },
    mounted() {
      this.gettravelList()

    },
  };
</script>

<style scoped>
</style>